package com.xxl.vueadmin.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.xxl.vueadmin.utils.Const;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * @version 1.0
 * @Author: 许啸林 mp自动填充处理类
 * @Date: 2021/7/28 16:52
 */
@Slf4j
@Component
public class MpMetaObjectHandel implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("start insert fill ....");
        this.setFieldValByName("deleted", Const.ISNT_DELETE, metaObject);
        this.setFieldValByName("statu", Const.STATU_ON, metaObject);
        this.setFieldValByName("created", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updated", new Date(), metaObject);
    }

}
